﻿using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace easyui.Models
{
   public enum TreeStates{
        open ,
        closed
    }
    public class EasyuiMenu
    {
        /// <summary>
        /// 节点ID，对加载远程数据很重要。
        /// </summary>
        public string id { get; set; } = "";
        /// <summary>
        /// 显示节点文本
        /// </summary>
        public string text { get; set; } = "";
        /// <summary>
        /// 节点状态，'open' 或 'closed'，默认：'closed'。如果为'closed'的时候，将不自动展开该节点。
        /// </summary>
        [JsonConverter(typeof(StringEnumConverter))]//加上这个特性，才能正确序列化枚举名称,不加 state的值就是 0,1,...
        public TreeStates state { get; set; } = TreeStates.closed;
        
        /// <summary>
        /// 该节点是否被选中。
        /// </summary>
        public bool @checked {get;set;}

        /// <summary>
        /// 绑定该节点的自定义属性。
        /// </summary>
        public string attributes { get; set; }
        /// <summary>
        /// 显示的节点图标CSS类ID
        /// </summary>
        public string iconCls { get; set; }

        public List<EasyuiMenu> children { get; set; }
    }

    public class EasyuiMenuChild
    {
        public List<EasyuiMenu> children { get; set; }
    }
}
